home *** CD-ROM | disk | FTP | other *** search
- /*
- * Winaux functions module
- *
- * Written by Bill Hall
- * 3665 Benton Street, #66
- * Santa Clara, CA 95051
- *
- */
-
- #define NOCOMM
- #include <string.h>
- #include <stdlib.h>
- #include <ascii.h>
- #include <windows.h>
- #include <ttycls.h>
- #include "winaux.h"
-
- /* local function declaractions */
- static void NEAR ShowAboutBox(HWND hWnd);
-
- void NEAR DispatchString(HWND hWnd, WORD wParam, LONG lParam)
- {
-
- BYTE buf[100];
- int len, i;
-
- len = min((int)wParam, 100);
- for (i = 0; i < len; i++)
- buf[i] = *(LPSTR)(lParam + i);
- TTYDisplay((PTTYWND)GetWindowWord(hWnd,0),(short)len, buf);
- }
-
- static void NEAR ShowAboutBox(HWND hWnd)
- {
-
- FARPROC fp;
- HANDLE hInstance = GetWindowWord(hWnd, GWW_HINSTANCE);
-
- /* make a proc instance for the about box window function */
- fp = MakeProcInstance((FARPROC)AboutBoxProc, hInstance);
- /* create a modal dialog box */
- DialogBox(hInstance, MAKEINTRESOURCE(DT_ABOUT),hWnd,fp);
- }
-
- /* process the menu */
- void NEAR WndCommand(HWND hWnd, WORD wParam)
- {
-
- HMENU hMenu = GetMenu(hWnd);
-
- switch (wParam) {
-
- case IDM_ABOUT:
- ShowAboutBox(hWnd);
- break;
-
- case IDM_CRONLF:
- MWnd.CRonLF = (MWnd.CRonLF ? FALSE : TRUE);
- CheckMenuItem(hMenu,wParam,MWnd.CRonLF ? MF_CHECKED : MF_UNCHECKED);
- break;
- }
- }
-
- /* paint the main window */
- void NEAR MainWndPaint(hWnd, lpps)
- HWND hWnd;
- LPPAINTSTRUCT lpps;
- {
-
- HDC hDC = lpps->hdc;
-
- /* if the window is iconic, draw the icon */
- if (IsIconic(hWnd)) {
- RECT rIcon;
- GetClientRect(hWnd, (LPRECT)&rIcon);
- Rectangle(hDC, 0,0,rIcon.right, rIcon.bottom);
- TextOut(hDC,2,rIcon.bottom/3,(LPSTR)szIconTitle,strlen(szIconTitle));
- }
- /* otherwise update the text in the window */
- else
- TTYWndPaint(&MWnd, lpps->hdc, lpps->rcPaint.top, lpps->rcPaint.bottom);
- }
-
- /* set the window handle variable */
- int SetWinIni(HWND hWnd)
- {
- char buf[20];
- return (WriteProfileString((LPSTR)szAppName, (LPSTR)szhWnd,
- (LPSTR)itoa(hWnd, buf, 10)));
- }
-
- /* adjust where text is to be displayed if window is resized */
- void NEAR AdjustHeight(short width, short height)
- {
-
- MWnd.Width = width;
- MWnd.Height = height;
- MWnd.Pos.y = height - MWnd.CHeight - 1;
- InvalidateRect(MWnd.hWnd, (LPRECT)NULL, TRUE);
- }
-
- /* This is the window proc for the about box when it is displayed */
- BOOL FAR PASCAL AboutBoxProc(hDlg, message, wParam, lParam)
- HWND hDlg;
- unsigned message;
- WORD wParam;
- LONG lParam;
- {
-
- switch (message) {
-
- /* nothing to initialize */
- case WM_INITDIALOG:
- break;
-
- /* this dialog box has only an OK button */
- case WM_COMMAND:
- switch (wParam) {
- case IDOK:
- /* destroy the dialog box */
- EndDialog(hDlg,TRUE);
- break;
- default:
- return FALSE; /* we did not process */
- }
-
- default:
- return FALSE;
- }
- return TRUE; /* we processed message */
- }